<?php
// Get a file into an array.  In this example we'll go through HTTP to get
// the HTML source of a URL.
$lines = file('/var/www/ac/acserver.log');


$gs=0;

$gresult;

//echo "<pre>";
// Loop through our array, show HTML source as HTML source; and line numbers too.
foreach ($lines as $line_num => $line) {




	if(strcmp(substr($line,0,1),"[")==0){
		echo $line."<br/>";
	}



        if(strcmp(substr($line,0,11),"Game start:")==0){		
		echo '<h4><FONT COLOR="#00FF00">' . htmlspecialchars($line).'</FONT></h4>' ;

		if($gs==3){
			echo "</table>";
		}

		$gs=1;
	}


        if($gs==3){

		for ($i = 0; $i <= 10; $i++) {
                    $line=str_replace("  "," ",$line);
                }


                $cols=split(" ",trim($line));

		//print_r($cols);
		if(count($cols)==6){		

			echo "<tr>";

        	        for ($j = 0; $j <= 5; $j++) {
                	    echo "<td>".$cols[$j]."</td>";
              		}

                	echo "</tr>";
		}


        }



        if($gs==2){
		
		for ($i = 0; $i <= 3; $i++) {
		    $line=str_replace("  "," ",$line);
		}

		echo '<table border="1" ><tr>';

		$cols=split(" ",$line);

		for ($j = 0; $j <= 5; $j++) {
                    echo "<td>".$cols[$j]."</td>";
                }	

		echo "</tr>";

		$gs=3;
        }



	if($gs==1){

		$parts=split(",",$line);
		if(count($parts)==3){
			if(strcmp($parts[1]," game finished")==0){
				echo '<h4><FONT COLOR="#FF0000">'.htmlspecialchars($line).'</FONT><h4>' ;
				$gs=2;
			}
		}
	}


}

//echo "</pre>";
// Another example, let's get a web page into a string.  See also file_get_contents().
//$html = implode('', file('http://www.example.com/'));

// Using the optional flags parameter since PHP 5
//$trimmed = file('somefile.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
?>
